<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
<script src="http://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
</head>

<body>
	<div class='input-group form-inline'>
		<form action="">
			<input type='text' class='form-control'
				style='width: 30%; margi n-bottom: 2px;' name='one[]'
				placeholder='输入一级菜单'> <input type='text'
				class='form-control' style='width: 30%; margin-bottom: 2px;'
				name='second[]' placeholder='请输入二级名字'> <input type='text'
				name='url[]' class='form-control'
				style='width: 30%; margin-bottom: 2px;' placeholder='请输入二级菜单url'>

			<input type='text' class='form-control'
				style='width: 30%; margin-bottom: 2px;' name='one[]'
				placeholder='输入一级菜单'> <input type='text'
				class='form-control' style='width: 30%; margin-bottom: 2px;'
				name='second[]' placeholder='请输入二级名字'> <input type='text'
				name='url[]' class='form-control'
				style='width: 30%; margin-bottom: 2px;' placeholder='请输入二级菜单url'>

			<input type='text' class='form-control'
				style='width: 30%; margin-bottom: 2px;' name='one[]'
				placeholder='输入一级菜单'> <input type='text'
				class='form-control' style='width: 30%; margin-bottom: 2px;'
				name='second[]' placeholder='请输入二级名字'> <input type='text'
				name='url[]' class='form-control'
				style='width: 30%; margin-bottom: 2px;' placeholder='请输入二级菜单url'>
			<button type="button" class="btn btn-block sub" >提交</button>
	</div>
	</form>
	<script>
		$(function() {
			$('.sub').click(function (){
				var valArr = new Array;
				var valArr1 = new Array;
				var valArr2 = new Array;
				$("input[name='one[]']").each(function(index, item) {
					valArr[index] = $(this).val();
					var priv = valArr.join(',');

				});
				$("input[name='second[]']").each(function(index, item) {
					valArr1[index] = $(this).val();
					var priv = valArr1.join(',');

				});
				$("input[name='url[]']").each(function(index, item) {
					valArr2[index] = $(this).val();
					var priv = valArr2.join(',');

				});
				console.log(valArr);
				console.log(valArr1);
				console.log(valArr2);
				
				var view ;
				view = {
					"button" : [ {
						"name" : valArr[0],
						"sub_button" : [ {
							"type" : "view",
							"name" : valArr1[0],
							"url" : valArr2[0],
							"sub_button": [ ]
						} ]
					}, {
						"name" : valArr[1],
						"sub_button" : [ {
							"type" : "view",
							"name" : valArr1[1],
							"url" : valArr2[1],
							"sub_button": [ ]
						} ]
					}, {
						"name" : valArr[2],
						"sub_button" : [ {
							"type" : "view",
							"name" : valArr1[2],
							"url" : valArr2[2],
							"sub_button": [ ]
						} ]
					} ]
				
				}
				console.log(view);
				 var viewto=JSON.stringify(view);
				 console.log(viewto);
				$.post("${basepath}/weixin/menu/modify.znck",
						{ menujson : viewto},
						function(data,testStatus){
							var result=data;
							console.log(data);
						});
			});
		})
	</script>

</body>
</html>